/**
 * Created by aaronjin on 16/11/24.
 */

var unit={};
/**
 * 循环对象取字符串对象插入
 *
 * @param Object
 * @param Result
 */
unit.loopObject=function (Object,Result){
    if(typeof(Object)=='object'){
        for(var subObject in Object){
            if(typeof(Object[subObject])!='string' && !(Object[subObject] instanceof Array)){
                unit.loopObject(Object[subObject],Result);
            }else{
                Result[subObject]=unit.pushArray(new Array(),Object[subObject]);
            }
        }
    }
};

/**
 * 将字符串或数组插入已有数组
 *
 * @param Result
 * @param Object
 * @returns {*}
 */
unit.pushArray=function (Result,Object){
    if(Object instanceof Array){
        Object.forEach(function(subObject){
            Result = unit.pushArray(Result,subObject);
        })
    }else{
        Result.push(Object);
    }
    return Result;
};
module.exports=unit;